package bsr.basara.autodata.job;

import bsr.basara.autodata.dao.TableInfoRepository;
import bsr.basara.autodata.entity.TableInfo;
import bsr.basara.autodata.service.impl.AutoDataService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 数据自动生成任务
 *
 * @author basara
 */
@Component
public class AutoDataJob {

    @Resource
    private TableInfoRepository tableInfoRepository;

    @Resource
    private AutoDataService autoDataService;

    /**
     * 历史数据生成任务
     */
    @Scheduled(cron = "0 1/15 * * * ? ")
    public void test() {
        List<TableInfo> hisTables = tableInfoRepository.findByType(2);
        for (TableInfo tableInfo : hisTables) {
            autoDataService.autoData(tableInfo);
        }
    }

}
